package com.example.cloud.rabbit.producer;

import lombok.RequiredArgsConstructor;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @author ccubee
 * @since 21-3-10 20:57
 */
@RestController
@RequiredArgsConstructor
public class ProducerRest {

    private final StreamBridge streamBridge;

    /**
     *  方式二 触发后接收消息
     */
    @RequestMapping("/send1")
    public String send1() {
        streamBridge.send("sink1-out-0", new Date());
        return "success1";
    }

    @RequestMapping("/send2")
    public String send2() {
        streamBridge.send("sink2-out-0", LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
        return "success2";
    }



}
